package cn.dansj.configure;

import cn.dansj.enums.GlobalEnv;
import org.springframework.context.annotation.*;
import org.springframework.data.redis.core.script.DefaultRedisScript;

@Configuration
public class RedisConfigure {
    @Bean(name = "limitScript")
    DefaultRedisScript<Long> limitScript() {
        DefaultRedisScript<Long> script = new DefaultRedisScript<>();
        script.setResultType(Long.class);
        script.setScriptText(GlobalEnv.RedisLimitScript);
        return script;
    }

    @Bean(name = "countScript")
    DefaultRedisScript<Long> countScript() {
        DefaultRedisScript<Long> script = new DefaultRedisScript<>();
        script.setResultType(Long.class);
        script.setScriptText(GlobalEnv.RedisTokenCountScript);
        return script;
    }
}
